import { defineStore } from "pinia";

export const storeUser = defineStore("user", {
  persist: true,
  state: () => ({
    UserId: null,
    UserAccount: "",
    UserName: "",
    PhoneNumber: "",
    RoleType: null,
    RoleName: "",
    DepartmentId: null,
    DepartmentName: null,
    Email: "",
    Signature: null,
    headerurl: null,
    is_stop: 0,
    ReadCount: 0,
    Rank: 0,
    Pics: 0,
    RightsOfDepartments: [],
  }),
  actions: {
    async setUser(data) {
      for (let i in data) {
        this[i] = data[i];
      }
    },
    clearUser() {
      this.UserId = null;
      this.UserAccount = "";
      this.UserName = "";
      this.PhoneNumber = "";
      this.RoleType = null;
      this.RoleName = "";
      this.DepartmentId = null;
      this.DepartmentName = null;
      this.Email = "";
      this.Signature = null;
      this.headerurl = null;
      this.is_stop = 0;
      this.ReadCount= 0
      this.Rank= 0
      this.Pics= 0
      this.RightsOfDepartments= []
    },
  },
});
